
local funcs = {}

funcs["hg"] = function( hero,args )
	local entity = Entities:FindByName(nil, "teleport_hg");
	FindClearSpaceForUnit(hero,entity:GetAbsOrigin() , true)
	local id = hero:GetPlayerOwnerID()
	hero:Stop()
	PlayerResource:SetCameraTarget(id, hero)
	local selfGameMode = GameRules:GetGameModeEntity()
	selfGameMode:SetContextThink(DoUniqueString("cameraMove"),
	function (  ) PlayerResource:SetCameraTarget(id, nil) end,0.5)
end

funcs["hc"] = function( hero,args )
	local entity = Entities:FindByName(nil, "teleport_hc");
	FindClearSpaceForUnit(hero,entity:GetAbsOrigin() , true)
	local id = hero:GetPlayerOwnerID()
	hero:Stop()
	PlayerResource:SetCameraTarget(id, hero)
	local selfGameMode = GameRules:GetGameModeEntity()
	selfGameMode:SetContextThink(DoUniqueString("cameraMove"),
	function (  ) PlayerResource:SetCameraTarget(id, nil) end,0.5)
end

funcs["testm"] = function ( hero,args )
	hero:AddNewModifier(hero, nil,"modifier_command_restricted",{})
end

funcs["test_info"] = function( hero,args )
	local infos = {}
	local playerlist = GameRules.playerlist
	for i,v in ipairs(playerlist) do
		local t = {
			playerid = v,
			cities = roleData.getCitiesById(v),
			steamid = tostring(PlayerResource:GetSteamID(v)),
		}
		table.insert(infos,t)
	end
	print(hPlayer)
	dump(infos,"infos = ")
	if hPlayer then
		CustomGameEventManager:Send_ServerToPlayer(hPlayer,"S2C_CREATE_PLAYER_INFO",{infos = infos})
	else
		CustomGameEventManager:Send_ServerToAllClients("S2C_CREATE_PLAYER_INFO", {infos = infos})
	end
end

funcs["addcity"] = function ( hero,args )
	local cityid = tonumber(args[1])
	roleData.addCityById(hero:GetPlayerOwnerID(),cityid)
end

funcs["removecity"] = function ( hero,args )
	local cityid = tonumber(args[1])
	roleData.removeCityById(hero:GetPlayerOwnerID(),cityid)
end

funcs["startpm"] = function ( hero,args )
	local cityid = tonumber(args[1])
	roleData.startPM(hero:GetPlayerOwnerID(),cityid)
end

funcs["siyecao"] = function( hero,args )
	block.OnSiyecao(hero)
end

funcs["baoxiang"] = function( hero,args )
	block.OnBaoXiang(hero)
end

funcs["zhuanpan"] = function( hero,args )
	block.OnZhuanPan(hero)
end

funcs["zuolao"] = function ( hero,args )
	block.Zuolao(hero)
end
--can't use model for SetAngles's z params doesn't function
funcs["dice"] = function( hero,args )
	local pts = ParticleManager:CreateParticle("particles/rotation.vpcf",PATTACH_WORLDORIGIN,hero)
	ParticleManager:SetParticleControl(pts, 3, Vector(0,0,300))
	local tornado = ParticleManager:CreateParticle("particles/units/heroes/hero_invoker/invoker_tornado_funnel.vpcf",PATTACH_WORLDORIGIN,hero)
	ParticleManager:SetParticleControl(tornado, 3, Vector(0,0,300))
	if GameRules.dice1 then
		ParticleManager:DestroyParticle(GameRules.dice1,false)
	end
	Timers:CreateTimer(2.5,function (  )
		ParticleManager:DestroyParticle(pts,false)
		ParticleManager:DestroyParticle(tornado,false)
		local rd = RandomInt(1,6)
		local partName = string.format("particles/dice_%d.vpcf",rd)
		GameRules.dice1 = ParticleManager:CreateParticle(partName,PATTACH_WORLDORIGIN,hero)
		ParticleManager:SetParticleControl(GameRules.dice1, 3, Vector(0,0,300))
	end)
end

funcs["goto"] = function ( hero,args )
	local point = tonumber(args[1])
	local unitName = hero:GetUnitName()
	gameControl[unitName](hero,point)
end

funcs["setgold"] = function( hero,args )
	local gold = tonumber(args[1])
	local id = hero:GetPlayerOwnerID()
	ModifyGoldLtx(id,gold)
end

funcs["finishGame"] = function( hero,args )
	gameControl.stopGameControl()
end

--一个测试命令必须至少要包含一个空格
function Kekaishi:test_chat(hero,cmd,args,isAdmin)
	print(cmd,args)
	if args then
		args = string.split(args," ")
	end
	if IsInToolsMode() or isAdmin then
		if funcs[cmd] then
			funcs[cmd](hero,args)
		end
	end
end